const Mock=require("mockjs");
const data=Mock.mock({
    "list|10":[
        {
            img:"@image(100x100,@color)",
            title:"@ctitle",
            "price|1-100.1":0,
            id:"@id"
        }
    ]
})
module.exports={
    devServer:{
        before(app){
            app.get("/list",(req,res)=>{
                res.send(data.list);
            })
            app.get("/detail",(req,res)=>{
                let {id}=req.query;
                console.log(id);
                let newArr=data.list.filter((item) => {
                    return item.id==id
                })
                res.send(newArr[0]);
            })
        }
    }
}